package SwordFingerOffer;

import java.util.Stack;

public class Q09_TwoStack2Queue {

    //双栈组队列
    Stack<Integer> main;
    Stack<Integer> help;


    public Q09_TwoStack2Queue() {
        this.main = new Stack<>();
        this.help = new Stack<>();
    }

    //尾插
    public void appendTail(int value) {
        main.add(value);
    }

    //删头
    public int deleteHead() {
        if (help.isEmpty() && !main.isEmpty()){
            while (!main.isEmpty()){
                help.add(main.pop());
            }
            return help.pop();
        }
        if (!help.isEmpty()){
            return help.pop();
        }
        return -1;
    }
}
